//
//  CCSkeletonCache.h
//  CCCSpine
//
//  Created by bin_you on 13-5-24.
//
//

#ifndef __CCCSpine__CCSkeletonCache__
#define __CCCSpine__CCSkeletonCache__

#include "CCSpineObject.h"
#include "CCSpineGlobal.h"
#include "CCSkeleton.h"



/**
 * cache of skeletal animation, singleton pattern
 */
class CCSkeletonCache : public CCSpineObject {
private:
	/// animation map
	typedef map<const char*, CCSkeleton*, CCSpineGlobal::CCStrPredicate> SkeletonMap;
	SkeletonMap m_skeletonMap;
    
    static CCSkeletonCache* _pInstance;
	
protected:
	CCSkeletonCache();
	
public:
	virtual ~CCSkeletonCache();
	
	/// get singleton instance, or create a new one if not existent
	static CCSkeletonCache* getInstance();
	
	/// add an Skeleton, the Skeleton must have a name set
	void addSkeleton(CCSkeleton* skel);
	
	/// add an Skeleton, and the name of Skeleton will be set
	void addSkeleton(const char* key, CCSkeleton* skel);
    CCSkeleton* loadSkeleton(const char* key,const char* jsonPath);
	
	/// get an Skeleton by name
	CCSkeleton* getSkeleton(const char* name);
    
	/// remove all cached Skeleton
	void purgeCache();
    
    void removeSkeleton(const char* name);
};



#endif /* defined(__CCCSpine__CCSkeletonCache__) */
